#ifndef AUDIOCLIENT_H
#define AUDIOCLIENT_H
#include <xmmsclient/xmmsclient++.h>
#include <QObject>
#include <QString>
#include <QStandardItemModel>

class AudioClient : public QObject
{

    Q_OBJECT


public:
    AudioClient();
    void add(const QString& fileName);
    void setPlaylistModel(QStandardItemModel* model);
    void loadPlaylist();
    void seek(const int& milliseconds);
    void playlistRemoveEntry(const int& position);

public slots:

    void clear();
    void next();
    void pause();
    void play();
    void play(const QModelIndex& index);
    void prev();
    void stop();

signals:

    void playlistCleared();
    void playtime(const int& value);
    void currentSongDuration(const int& value);
    void currentPosition(const unsigned int& value);
    void removedEntry(const int& value);

private:
    Xmms::Client client_;
    QStandardItemModel* model_;

private:
    bool loadPlaylistEntries(const Xmms::List< unsigned int >& list);
    bool appendToModel(const Xmms::PropDict& propdict);
    void extractQStringFromDict(QString& recipient, const Xmms::PropDict& dict, const std::string& mykey);
    bool playlistChangedSignal(const Xmms::Dict& eventType);
    bool playtimeSignal(const unsigned int& playtime);
    bool updateCurrentPlaybackInfo(const unsigned int& id);
    bool updateCurrentPlaybackInfoFromDict(const Xmms::PropDict& info);
    bool updateStatus(const Xmms::Playback::Status& status);
    bool updateCurrentPosition(const Xmms::Dict& currentPositionDict);
};

#endif // AUDIOCLIENT_H
